package com.digital.welcome.controller;


import com.digital.welcome.annotation.OperationLog;
import com.digital.welcome.entity.Report;
import com.digital.welcome.service.ReportService;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 韩
 */
@RestController
@RequestMapping("/report")
public class ReportController {

    @Autowired
    private ReportService reportService;

    @ApiOperation("首页重要通知")
    @RequestMapping(value = "/select", method = RequestMethod.GET)
    public String getInformation() throws InterruptedException {
        return reportService.getAllInformation();
    }

    @ApiOperation("查询通知")
    @RequestMapping(value = "/selectReportInformation", method = RequestMethod.POST)
    public String selectReportInformation(@RequestBody Report report) throws InterruptedException {
        return reportService.selectReportInformation(report.getTitle());
    }

    @ApiOperation("发布通知")
    @RequiresPermissions("notice")
    @RequestMapping(value = "/push", method = RequestMethod.POST)
    public String insertContent(@RequestBody Report report) {
        return reportService.insertReport(report);
    }

    @OperationLog()
    @ApiOperation("删除report")
    @RequiresPermissions("notice")
    @RequestMapping(value = "/delete", method = RequestMethod.DELETE)
    public String deleteSchoolInformation(@RequestBody Report report) {
        return reportService.deleteReport(report);
    }

    @OperationLog()
    @ApiOperation("修改文章")
    @RequiresPermissions("notice")
    @RequestMapping(value = "/updateInformation", method = RequestMethod.POST)
    public String supdateInformation(@RequestBody Report report) {
        return reportService.updateInformation(report);
    }


}
